From 83b54bab5734f17d01633c1b5a0ce3e4896d2ee0 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Fri, 25 Nov 2016 14:24:52 +0100 Subject: [PATCH] wayland: Fix a race condition with xdg_popup resize When resizing an xdg_popup immediately after the initial mapping, there is a race condition between the client and the compositor which is processing the initial size given by the xdg_positioner, leading to the xdg_popup to be eventually of the wrong size. Only way to make sure the size is correct in that case is to hide and show the window again. Considering this occurs before the initial configure is processed, it should not be noticeable. https://bugzilla.gnome.org/show_bug.cgi?id=772505 --- gdk/wayland/gdkwindow-wayland.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 64b7356dc4..5c09541951 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -1001,13 +1001,30 @@ gdk_wayland_window_maybe_configure (GdkWindow *window, int scale) { GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + gboolean is_xdg_popup; + gboolean is_visible; if (window->width == width && window->height == height && impl->scale == scale) return; + /* For xdg_popup using an xdg_positioner, there is a race condition if + * the application tries to change the size after it's mapped, but before + * the initial configure is received, so hide and show the surface again + * force the new size onto the compositor. See bug #772505. + */ + + is_xdg_popup = (impl->display_server.xdg_popup != NULL); + is_visible = gdk_window_is_visible (window); + + if (is_xdg_popup && is_visible && !impl->initial_configure_received) + gdk_window_hide (window); + gdk_wayland_window_configure (window, width, height, scale); + + if (is_xdg_popup && is_visible && !impl->initial_configure_received) + gdk_window_show (window); } static void -- 2.30.2